<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use cmf\controller\HomeBaseController;

class NewsController extends HomeBaseController
{
    public function index()
    {
    	$product=db('portal_post')
    	->where(['comment_status'=>1])
    	->order('is_top desc,published_time desc')
    	->paginate(8,false,['query' => request()->param()]);
    	
    	
    	
    	$this->assign('news',$product->items());
    	$this->assign('page', $product->render());
    	
        return $this->fetch();
    }
	public function detail()
	{
		
		$id=request()->param('id',0,'intval');
		db('portal_post')->execute('update cmf_portal_post set post_hits=post_hits+1 where id='.$id);
		//p($id);
		$newsInfo=db('portal_post')->find($id);
		
		
		$this->assign('newsInfo',$newsInfo);
	    return $this->fetch();
	}
}
